//  
//  Sprawdzacz
//  
//  Author:
//       Grzegorz Żur <grzegorz.zur@gmail.com>
// 
//  Copyright (c) 2010-2011 Grzegorz Żur
// 
//  This program is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
// 
//  This program is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
// 
//  You should have received a copy of the GNU General Public License
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
//

using System;

using NUnit.Framework;
using NUnit.Framework.Constraints;
using NUnit.Framework.SyntaxHelpers;

using Sprawdzacz;

namespace Tests
{
	
	public class TestCase
	{
		private readonly Validator validator;
		
		private readonly string number;
		
		private readonly bool correct;
		
		private readonly string name;
		
		private readonly string[] texts;
		
		public TestCase (Validator validator, string number, bool correct, string name, params string[] texts) 
		{
			this.validator = validator;
			this.number = number;
			this.correct = correct;
			this.name = name;
			this.texts = texts;
		}
		
		[Test]
		public void Test ()
		{
			try {
				Validation validation = validator.Validate(number);
				Assert.That(validation, Is.Not.Null, "null validation");
				Assert.That(validation.Correct, Is.EqualTo(correct), "incorrect validation");
				Assert.That(validation.Name, Is.Not.Null, "null name");
				Assert.That(validation.Name, Is.EqualTo(name));
				foreach (string text in texts)
					Assert.That(validation.Message, Text.Contains(text));
			} catch (ValidationException e) {
				Assert.Fail("validation exception: {0}", e.Message);
			}
		}
		
	}
	
}
